#include <iostream>

#include "ItemActionMenu.h"
#include "PurchaseMenu.h"
#include "RestockMenu.h"

using std::cout;
using std::endl;

//Constructors

ItemActionMenu::ItemActionMenu(int itemType): SelectionMenu("Choose an action to perform:", "Back")
{
	addSelection("Purchase an item");
	addSelection("Restock an item");

	itemTypeID = itemType;
}

//Member Functions

void ItemActionMenu::performAction(Stock* companyStock, Cart* theCart)
{
	int userSelection;

	do {
		displayInfoBar();
		displayContent();
		cout << endl;

		userSelection = getSelectionFromUser();
		cout << endl;

		switch(userSelection)
		{
		case 1:
			PurchaseMenu* purchasePage = new PurchaseMenu(itemTypeID);
			purchasePage -> performAction(companyStock, theCart);
			delete purchasePage;
			break;
		case 2:
			RestockMenu* restockPage = new RestockMenu(itemTypeID);
			restockPage -> performAction(companyStock);
			delete restockPage;
			break;
		case 0:
			break;
		}
	} while (userSelection != 0);

	cout << endl;
}